<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
$config = array(
		//
		'cname' => 'item',
		
		//
		'class_file' => 'module/blog/blog.content.class.php',
		'class_name' => 'BlogContentBase',
		'class_param' => array('_table_status_usable' => false),
		
		//
		'tpl_type' => 'front',
		'tpl_file' => 'pagelayout/pagelayout_main_blog.tpl',
		
		//
		'validate_file' => '',
		'validate_class' => 'CommonValidate',
		'validate_fields' => array('field' => 'name', 'valid' => 'null'),
			);

//
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'control/front/item.front.control.class.php');

//
class _ControlItemBase extends ControlItemBase {
	
	//constructor
	function _ControlItemBase($config = '') {
		parent::ControlItemBase($config);
		
		//
		if( $this->feObj->request_link_class == 'index' ) {
			$this->displayHandler = '';
		} elseif( $this->feObj->request_link_class != '' ) {
			$this->displayHandler = 'doDetailDisplayHandler';
		}
	}
	
	//methods
	function doDetailDisplayHandler($obj) {
		$link = $this->feObj->request_link_class;
		$_valid = $this->modelObj->checkItem($link, 'link');
		if( $_valid == true ) {
			$item = $this->modelObj->getItem($link, 'link');
			
			$this->feObj->content_wrap['mainpart'] = 'item';
			$this->feObj->content_wrap['item'] = $item;
		} else {
			$this->feObj->content_wrap['mainpart'] = $this->_make_request('no');
		}
		
		//
		$this->feObj->addTitle($item['subject'], ' - ');
	}
	
	//
	function _doBefore() {
		$this->feObj->addContext('permission', array('comments' => 1, 'addcomment' => 1, 'listcomment' => 1));
	}
	
	function _doAfter() {
		
	}
}

//
$cntlObj = new _ControlItemBase($config);
$cntlObj->process();
//
?>